<?php
/**
 *
 * @Author nikm $
 *
 * @Date 2012-3-9 $
 */

if(!defined('FROM_INDEX')) exit('Invalid request');

//require ROOT_PATH.'include/lib/cookie.func.php';
require ROOT_PATH.'include/sql/sql_functions.php';
require ROOT_PATH.'servlet/include/function/sql.func.php';

class masterObj
{
	var $config = array();
	var $request = array();
	var $response = array();
	
	var $act = '';
	var $user = array();
	
	function __construct($request)
	{
		load_setting('config_global');
		
		$this->request = $request;
		$this->act = $request['a'];
		
		$this->request['limit'] = isset($request['count'])? min(500, max((int)$request['count'], 10)) : 10;
		$this->request['offset'] = isset($request['page']) ? max(0, (int)$request['page'] - 1) : 0;
		
		if(isset($this->request['latitude_']))
		{
			$this->request['latitude'] = (float)$this->request['latitude_'];
			unset($this->request['latitude_']);
		}
		else if(isset($this->request['latitude']))
		{
			$this->request['latitude'] = (float)$this->request['latitude'];
		}
		
		if(isset($this->request['longitude_']))
		{
			$this->request['longitude'] = (float)$this->request['longitude_'];
			unset($this->request['longitude_']);
		}
		else if(isset($this->request['longitude']))
		{
			$this->request['longitude'] = (float)$this->request['longitude'];
		}
	}
	
	function message($code, $status=STATUS_S)
	{
		show_msg($this->request, $code, $status);
	}
	
	function showResponse()
	{
		show_response($this->request, $this->response);
	}
	
	protected function createPassword($date, $password)
	{
		$validate_pwd = password_hash($date, $password);
		
		return $validate_pwd;
	}

}